<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      >
    <html>
        <h:head>
        </h:head>
        <h:body>
            <f:facet name="last">
                <h:outputStylesheet library="css" name="primefaces-override.css"/>
            </f:facet>
            <p:growl id="mensajes" showDetail="true" life="2000" />
            <p:layout fullPage="true">
                <p:layoutUnit position="center" 
                              closable="false" 
                              collapsible="false" 
                              styleClass="layoutBorderNone">
                    <h:form>                       
                                                                                             
                        <h:message for="username" style="color:red" /> 
                        
                        <center>
                            
                            <p:panel style="width:90%;margin-top: 5%;border: none;border-width: 0px"  >
                                <h2><h:outputLabel id="tituloSistema" 
                                                   value="#{inter['inicio.tituloSistema']}" />
                                </h2>
                            </p:panel>
                            
                            <p:panel style="width:300px;margin-top: 1%;" styleClass="panelTitleBarLogin">
                                <f:facet name="header">#{inter['inicio.panelTitulo']}</f:facet>
                                <h:panelGrid columns="2" cellpadding="5" >
                                    <h:outputLabel id="lblUsuario"  value="#{inter['inicio.lblUsuario']}" />
                                    <h:inputText value="#{loginBean.nombre}" 
                                                 id="txtusername"
                                                 maxlength="10" 
                                                 tabindex="10"
                                                 >
                                        <f:validator validatorId="validator.LoginValidator"  />
                                    </h:inputText>   
                                    
                                    <h:outputLabel id="lblClave" for="password" value="#{inter['inicio.lblClave']}" />
                                    <p:password value="#{loginBean.clave}" 
                                                id="txtpassword" 
                                                maxlength="10"
                                                tabindex="20">
                                        <f:validator validatorId="validator.LoginValidator"  />
                                    </p:password>
                                    
                                    <f:facet name="footer">
                                        <p:commandButton id="cmdLogin" 
                                                         value="#{inter['inicio.cmdLogin']}"
                                                         style="width: 100%"
                                                        actionListener="#{loginBean.login}" 
                                                        update=":mensajes"
                                                        oncomplete="manejarLogin(xhr, status, args)" />
                                    </f:facet>
                                </h:panelGrid>
                                            
                            </p:panel>
                        
                        </center>
                    </h:form>
                </p:layoutUnit>
                <p:layoutUnit position="south" 
                              size="35" 
                              closable="false" 
                              collapsible="false" 
                              style="text-align:right;" 
                              styleClass="layoutBorderNoneRightPad">
                    <h:form >
                        <h:graphicImage value="resources/images/language.png" 
                                        alt="#{inter['inicio.txtLenguaje']}" 
                                        title="#{inter['inicio.txtLenguaje']}"
                                        style="vertical-align: middle"/>
                            <h:selectOneMenu value="#{lenguaje.localeCode}" 
                                             onchange="submit()"
                                             valueChangeListener="#{lenguaje.countryLocaleCodeChanged}"
                                             style="height: 21px;vertical-align: middle">
                                <f:selectItems value="#{lenguaje.countriesInMap}" /> 
                            </h:selectOneMenu>
                    </h:form>
                </p:layoutUnit>
            </p:layout>
        </h:body>
<script type="text/javascript">
  //<![CDATA[
  function manejarLogin(xhr, status, args) {
    if (!args.validationFailed && args.estaLogeado) {
      setTimeout(function() {
        window.location = args.view;
      }, 500);
    }
  }
//]]>
</script>
    </html>
</f:view>
<!--
http://incepttechnologies.blogspot.com/p/validation-in-jsf.html
-->